using Game.Main.Model;
using Game.XH;
using UnityEngine;

namespace Game.Component
{
	public class WaxingMachineItem : BaseItem
	{
		public enum Anim
		{
			Static = 0,
			Shake = 1
		}

		private Anim anim;

		private Vector3 originalPos;

		public override void Init(ItemArchiveData data)
		{
			base.Init(data);
			originalPos = model.localPosition;
		}

		protected override void LateUpdate()
		{
			base.LateUpdate();
			if (anim != 0 && anim == Anim.Shake)
			{
				model.SetLocalXY(originalPos.x + Random.Range(-0.04f, 0.04f), originalPos.y + Random.Range(-0.04f, 0.04f));
			}
		}

		public override void TouchDown(TouchEventData touchEventData)
		{
			anim = Anim.Shake;
			base.TouchDown(touchEventData);
		}

		public override void TouchUp(TouchEventData touchEventData)
		{
			anim = Anim.Static;
			model.SetLocalXY(originalPos.x, originalPos.y);
			base.TouchUp(touchEventData);
		}
	}
}
